class Solution
{
private:
    bool isPalindrome(string& s, int left, int right)
    {
        for (; left < right; ++left, --right)
            if (s[left] != s[right])
                return false;

        return true;
    }

public:
    bool validPalindrome(string s)
    {
        for (int l = 0, r = s.size() - 1; l < r; ++l, --r)
            if (s[l] != s[r])
                return isPalindrome(s, l + 1, r) || isPalindrome(s, l, r - 1);

        return true;
    }
};